package com.lvyq.myplayer.widget.singer

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.lvyq.myplayer.R
import com.lvyq.myplayer.model.singer.SingerAlbumData
import com.squareup.picasso.Picasso

/**
 * 文件描述：SingerAlbumView
 * 作者：lvyq
 * 创建时间：2025-03-05
 * 修改时间：2025-03-05
 */
class SingerAlbumView:RelativeLayout {

    lateinit var img:ImageView
    lateinit var albumName:TextView

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    init {
        var view = View.inflate(context, R.layout.item_singer_album, this)
        img=view.findViewById<ImageView>(R.id.img)
        albumName=view.findViewById<TextView>(R.id.albumName)
    }
    fun setData(data: SingerAlbumData) {
        if (!data.bgImg.equals("")){
            Picasso.with(context).load(data.bgImg).into(img)
        }
        //立即显示滚动效果
        albumName.isSelected = true
        albumName.text=data.albumName
    }
}